﻿using System.Data;
using DataObject;

namespace Event.Controls.Homepage
{
    public partial class QAHomePage : System.Web.UI.UserControl
    {
        #region variables, constants, properties
        private const string LI_FORMAT = @"<li class=""{2}""><p class=""question""><label class=""dot""></label>{0}</p><p class=""answer"">{1}</p></li>";
        #endregion

        internal bool DataBind(DataTable dt)
        {
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var r = dt.Rows[i];
                    var cls = string.Empty;
                    if (i == 2) cls = "last";
                    this.ltrList.Text += string.Format(LI_FORMAT,
                    r[Constants.Table_QA.QA_Text],
                    r[Constants.Table_QA.QA_Answer],
                    cls);
                }
                return true;
            }
            return false;
        }
    }
}